<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/hpp_c1_c2.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<title>Editor Grid</title>
<script src="<s:url value="/js/jquery-1.4.2.js"/>" language="javascript1.5" type="text/javascript"></script>
<link id="screenBaseCss" rel="stylesheet" type="text/css" href="<s:url value="/css/screen.css"/>"/>
<script src="<s:url value="/js/ejs/Grid/GridE.js"/>" type="text/javascript"> </script>
<link href="<s:url value="/js/ejs/Styles/vtc.css"/>" rel="stylesheet" type="text/css" />
<link href="<s:url value="/css/vtc_screen.css"/>" rel="stylesheet" type="text/css" />
<link id="coreBaseCss" rel="stylesheet" type="text/css" href="<s:url value="/css/core.css"/>"/>
<script language="javascript1.5" type="text/javascript" src="<s:url value="/js/config.js"/>" ></script>
<script language="javascript1.5" type="text/javascript" src="<s:url value="/js/core.js"/>" ></script>
<script language="javascript1.5" type="text/javascript" src="<s:url value="/js/popup.js"/>" ></script>
<script type="text/javascript">

var sType = ['B','C','D', 'E', 'F', 'G'];
function onOffCol(G, isShow){
	for(var i=0; i<sType.length; i++){
		if(G.Cols[sType[i]]){
			if(isShow){
				G.HideCol(sType[i]);
			}else{
				G.ShowCol(sType[i]);
			}
		}
	}
	return !isShow;
}

var show = false;
function hideColumns(obj){
	var grid = Grids['Level2Planning'];
	show = onOffCol(grid, show);
	if(show){
		obj.value = 'Hide Columns';		
	}else{
		obj.value = 'Show Columns';		
	}
}

function cancel(){
	window.location="plan-second!input.action?level2Planning.id=<s:property value='level2Planning.id'/>";
}

function confirm() {
	$.ajax({
		url : "plan-second!confirmForDetail.action?no-decorate&categoryNodeId=<s:property value='categoryNodeId'/>&level2Planning.id=<s:property value='level2Planning.id'/>",
		cache : true,
		dataType : "string",
		async : false,
		success : function(data) {
			document.getElementById("confirm").disabled="disabled";
			document.getElementById("save").disabled="disabled";
		},
		error : function(data) {
			//alert(data);
		}
	});
}

function searchByInService(){
	var searchByInService = document.getElementById("inService").value;
	window.location.href = "plan-second!viewDetail.action?no-decorate&disciplineType=<s:property value='disciplineType'/>&level2Planning.id=<s:property value='level2Planning.id'/>&categoryNodeId=<s:property value='categoryNodeId'/>&searchByInService="+searchByInService;
}

function toBreakDown(e,ppiId){
	popup(e, "plan-second!turnToBreakDownPage.action?no-decorate=0&programmePlanningItemId="+ppiId, "width:800;height:600;left:100;top:100");

}
</script>
<style>
.oddRowBgColor {
	background-color:#FF0 !important;
}
</style>

</head>

<body scroll="no" style="overflow:hidden">
<div class="body" style="height:100%;">
	  <s:actionerror/>
	  <s:fielderror id="fielderror" />
	  <s:actionmessage/> 
  <table style="height:100%; width:100%" border="0" cellpadding="0" cellspacing="0" >
    <tr>
      <td style="height:58px; background:#F00" ><div class="button-region-style">
          <div class="btnSet">
            <table width="95%" cellpadding="0" cellspacing="0" >
              <tr>
                <td><div class="left" >
                <s:if test="%{level1Status=='Endorsed'}">
               	 <div class="button" >
	                    <div class="left" >
	                      <div class="right" >
	                      <security:authorize access="hasRole('CONFIRMED_2ND_LEVEL')">
	                        <input class="inputButton" type="button" id="confirm" name="" value="Confirm and Submit for Endorsement" onClick="confirm()"/>
	                      <script>
		                    var canEdit = "<s:property value='canEdit'/>";
		                    if(canEdit == "false"){
		                    	document.getElementById("confirm").disabled="disabled";
		                    }
		                    </script>
	                      </security:authorize>
	                      </div>
	                    </div>
	                  </div>
                    </s:if>
                    <div class="button" >
                      <div class="left" >
                        <div class="right" >
                        <security:authorize access="hasRole('PLANNING_2ND_LEVEL_UPDATE')">
                          <input class="inputButton" type="button" id="save" name="" value="Save" onClick="Grids['Level2Planning'].Save();" />
                          <script>
		                    var canEdit = "<s:property value='canEdit'/>";
		                    if(canEdit == "false"){
		            			document.getElementById("save").disabled="disabled";
		                    }
		                    </script>
                          </security:authorize>
                        </div>
                      </div>
                    </div>
                    
                    <div class="button" >
                      <div class="left" >
                        <div class="right" >
                          <input class="inputButton" type="button" id="" name="" value="Cancel" onClick="cancel()" />
                        </div>
                      </div>
                    </div>
                    <div class="button" >
                      <div class="left" >
                        <div class="right" >
                          <input class="inputButton" type="button" id="hideColumns" name="" value="Hide Columns" onClick="hideColumns(this)" />
                        </div>
                      </div>
                    </div>
                  </div></td>
                  
                  <td><div class="right" style="color:#FFF; font-size:13px; font-weight:bold" >
                     <s:select cssClass="required" cssStyle="width:150px" name="programme.preEmploymentInService" id="inService"
            		  list="paramService.preEmploymentInServiceList" listKey="code" listValue="desc"
            		  value="%{searchByInService}" headerKey="" headerValue="-- Select --">
            		</s:select>
                    
                    <div class="button">
                      <div class="left" >
                        <div class="right" >
                          <input class="inputButton" type="button" id="" name="" value="&nbsp; Go &nbsp;" onClick="searchByInService()" />
                        </div>
                      </div>
                    </div>
                  </div></td>
                  
              </tr>
            </table>
          </div>
        </div>
        <div class="title-region-style"> 2nd Level Planning - (<s:property value='level2Planning.planning.category.planningExerciseName'/>)</div></td>
    </tr>
    <tr>
      <td style="vertical-align:top"><input type="hidden" name="disciplineType" id="disciplineType">
        <div style="width:100%;height:100%">
          <bdo Debug='0' 
               Data_Url="plan-second!getViewDetail.action?no-decorate&disciplineType=<s:property value='disciplineType'/>&level2Planning.id=<s:property value='level2Planning.id'/>&categoryNodeId=<s:property value='categoryNodeId'/>&searchByInService=<s:property value='searchByInService'/>"
               Upload_Url="plan-second!saveViewDetail.action?no-decorate&disciplineType=<s:property value='disciplineType'/>&level2Planning.id=<s:property value='level2Planning.id'/>&categoryNodeId=<s:property value='categoryNodeId'/>" Upload_Format="Internal" Upload_Data="viewDetailData" >
          </bdo>
        </div></td>
    </tr>
  </table>

</div>
<script type="text/javascript">

var icolor=0;
var iID=setInterval(setbgColor, 1000);
function setbgColor()
{
	try{
		hideColumns(document.getElementById("hideColumns"));
		clearInterval(iID);
	}catch(err){
		if((icolor+=1)>10) {
	    	clearInterval(iID);
	    }
	}
    
}

</script>
</body>
</html>

